import { getToken } from '@/utils/auth';

export default (options: any) => {
  return {
    searchFileds: [
      {
        span: 5,
        field: 'deptId',
        placeholder: '请输入所属科室',
        label: '所属科室',
        tag: 'a-tree-select',
        initValue: '',
        attrs: {
          'data': options.deptTree,
          'treeProps': {
            virtualListProps: {
              height: 200,
            },
          },
          'field-names': {
            key: 'id',
            title: 'label',
          },
          'allow-search': true,
          'allow-clear': true,
          'filter-tree-node': (
            searchValue: string,
            nodeData: { label: string }
          ) => {
            return (
              String(nodeData.label)
                .toLowerCase()
                .indexOf(String(searchValue).toLowerCase()) > -1
            );
          },
        },
      },
      {
        span: 5,
        field: 'nickName',
        placeholder: '请输入患者姓名',
        label: '患者姓名',
        tag: 'a-input',
        initValue: '',
      },
      {
        span: 5,
        field: 'idNumber',
        placeholder: '请输入身份证号',
        label: '身份证号',
        tag: 'a-input',
        initValue: '',
      },
      {
        span: 5,
        field: 'sex',
        placeholder: '请选择性别',
        label: '性别',
        initValue: '',
        tag: 'a-select',
        attrs: {
          options: options.sys_user_sex,
        },
      },
    ],
    tableColumns: [
      {
        dataIndex: 'id',
        title: '序号',
        width: 150,
      },
      {
        dataIndex: 'nickName',
        title: ' 患者姓名',
        width: 150,
      },
      {
        dataIndex: 'sex',
        title: '患者性别',
        slotName: 'sex',
        width: 100,
      },
      {
        dataIndex: 'idNumber',
        title: '身份证号',
        width: 200,
      },
      {
        dataIndex: 'breakfastPhoto',
        title: '早餐图片',
        slotName: 'breakfastPhoto',
      },
      {
        dataIndex: 'lunchPhoto',
        title: '午餐图片',
        slotName: 'lunchPhoto',
      },
      {
        dataIndex: 'dinnerPhoto',
        title: '晚餐图片',
        slotName: 'dinnerPhoto',
      },
      {
        dataIndex: 'remark',
        title: '备注',
        ellipsis: true,
        tooltip: true,
      },
      {
        dataIndex: 'createTime',
        title: '创建时间',
        width: 180,
      },
      {
        dataIndex: 'optional',
        title: '操作',
        slotName: 'optional',
        width: 220,
      },
    ],
    addFields: [
      {
        key: 'userId',
        label: '患者',
        tag: 'a-select',
        attrs: {
          options: options.userList,
          placeholder: '请选择患者',
          allowSearch: true,
        },
        decorator: {
          rules: [{ required: true, message: '请选择患者' }],
        },
      },
      {
        key: 'breakfastPhoto',
        label: '早餐图片',
        tag: 'XUpload',
        attrs: {
          config: {
            'list-type': 'picture-card',
            'action': `${import.meta.env.VITE_API_BASE_URL}${
              import.meta.env.VITE_UPLOAD_URL
            }`,
            'headers': {
              Authorization: `Bearer ${getToken()}`,
            },
            'imagePreview': true,
            'limit': 1,
            'accept': ['image/*'],
          },
        },
      },
      {
        key: 'lunchPhoto',
        label: '午餐图片',
        tag: 'XUpload',
        attrs: {
          config: {
            'list-type': 'picture-card',
            'action': `${import.meta.env.VITE_API_BASE_URL}${
              import.meta.env.VITE_UPLOAD_URL
            }`,
            'headers': {
              Authorization: `Bearer ${getToken()}`,
            },
            'imagePreview': true,
            'limit': 1,
            'accept': ['image/*'],
          },
        },
      },
      {
        key: 'dinnerPhoto',
        label: '晚餐图片',
        tag: 'XUpload',
        attrs: {
          config: {
            'list-type': 'picture-card',
            'action': `${import.meta.env.VITE_API_BASE_URL}${
              import.meta.env.VITE_UPLOAD_URL
            }`,
            'headers': {
              Authorization: `Bearer ${getToken()}`,
            },
            'imagePreview': true,
            'limit': 1,
            'accept': ['image/*'],
          },
        },
      },
    ],
    editFields: [
      {
        key: 'userId',
        label: '患者',
        tag: 'a-select',
        attrs: {
          options: options.userList,
          placeholder: '请选择患者',
          allowSearch: true,
          disabled: true,
        },
        decorator: {
          rules: [{ required: true, message: '请选择患者' }],
        },
      },
      {
        key: 'breakfastPhoto',
        label: '早餐图片',
        tag: 'XUpload',
        attrs: {
          config: {
            'disabled': true,
            'list-type': 'picture-card',
            'action': `${import.meta.env.VITE_API_BASE_URL}${
              import.meta.env.VITE_UPLOAD_URL
            }`,
            'headers': {
              Authorization: `Bearer ${getToken()}`,
            },
            'imagePreview': true,
            'limit': 9,
            'accept': ['image/*'],
          },
        },
      },
      {
        key: 'breakfastEvaluate',
        label: '早餐评价',
        tag: 'a-input',
        attrs: {
          placeholder: '请输入早餐评价',
        },
        decorator: {
          rules: [{ required: false, message: '请输入早餐评价' }],
        },
      },
      {
        key: 'lunchPhoto',
        label: '午餐图片',
        tag: 'XUpload',
        attrs: {
          config: {
            'disabled': true,
            'list-type': 'picture-card',
            'action': `${import.meta.env.VITE_API_BASE_URL}${
              import.meta.env.VITE_UPLOAD_URL
            }`,
            'headers': {
              Authorization: `Bearer ${getToken()}`,
            },
            'imagePreview': true,
            'limit': 9,
            'accept': ['image/*'],
          },
        },
      },
      {
        key: 'lunchEvaluate',
        label: '午餐评价',
        tag: 'a-input',
        attrs: {
          placeholder: '请输入午餐评价',
        },
        decorator: {
          rules: [{ required: false, message: '请输入午餐评价' }],
        },
      },
      {
        key: 'dinnerPhoto',
        label: '晚餐图片',
        tag: 'XUpload',
        attrs: {
          config: {
            'disabled': true,
            'list-type': 'picture-card',
            'action': `${import.meta.env.VITE_API_BASE_URL}${
              import.meta.env.VITE_UPLOAD_URL
            }`,
            'headers': {
              Authorization: `Bearer ${getToken()}`,
            },
            'imagePreview': true,
            'limit': 9,
            'accept': ['image/*'],
          },
        },
      },
      {
        key: 'dinnerEvaluate',
        label: '晚餐评价',
        tag: 'a-input',
        attrs: {
          placeholder: '请输入晚餐评价',
        },
        decorator: {
          rules: [{ required: false, message: '请输入晚餐评价' }],
        },
      },
      {
        key: 'totalEvaluate',
        label: '总评价',
        tag: 'a-input',
        attrs: {
          placeholder: '请输入总评价',
        },
        decorator: {
          rules: [{ required: false, message: '请输入总评价' }],
        },
      },
      {
        key: 'remark',
        label: '备注',
        tag: 'a-input',
        attrs: {
          placeholder: '请输入备注',
        },
        decorator: {
          rules: [{ required: false, message: '请输入备注' }],
        },
      },
    ],
  };
};
